package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;

@Controller //当前为类控制器
@ResponseBody //返回的是数据，不是页面
public class TestControler {

    @Value("${mytest}")
    private  String mytest;

    @Value("${mytest2}")
    private  String mytest2;


    @Value("${mystring}")
    private  String mystring;
    @Value("${mystring1}")
    private  String mystring1;
    @Value("${mystring2}")
    private  String mystring2;

    @Autowired
    private Student student;
    @PostConstruct
    public  void PostConstruct()
    {

        System.out.println(student);
        System.out.println(mystring);
        System.out.println(mystring1);
        System.out.println(mystring2);
    }
    @RequestMapping("/hi")
    public String sayhi(String name)
    {
        if(!StringUtils.hasLength(name))
        {
            name="zhangsan";
        }
        return "name:"+name;
    }
    @RequestMapping("/get")
    public String getname()
    {
        return "mytest:"+mytest+"mytest2:"+mytest2;
    }
}
